﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Guifreaks.NavigationBar;
using System.Xml;
using Microsoft.Xml.Serialization.GeneratedAssembly;
using System.IO;
using System.Windows.Forms.Calendar;


namespace Helix_Network_Supervisor_3
{
    public partial class MainForm : Form
    {
        #region Fields
        private ChannelMap channelMap = new ChannelMap();
        private Schedule schedule;
        private Playlist playlist = new Playlist();
        private Show show = new Show();
        private ApplicationSettings appSettings = new ApplicationSettings();
        private XBeeSerialPort xBee;
        private Control[] Editors;

        //private string playlistNeedsToBeSavedLabel = "";
        //private string playlistFoldersLabel = "";
        //private string playlistMP3sLabel = "";
        //private string playlistStatusLabel = "";

        #endregion Fields

        #region Ctor

        public MainForm()
        {
            InitializeComponent();
            schedule = new Schedule(calendarItemsImageList);
            InitializeAllControls();
            UpdateMainForm();
            xBeeBaudRateComboBox.SelectedIndex = 6;
            Editors = new Control[]
            {
                showPauseNameTextBox,
                showPauseDurationDateTimePicker
            };
            showPauseListViewEx.DoubleClickActivation = true;
            xBee = new XBeeSerialPort(xBeeComPortComboBox);
        }

        #endregion Ctor

        #region Properties

        #endregion Properties

        #region Public Methods


        #endregion Public Methods

        #region Private Methods

        /// <summary>
        /// Initialize All of the Controls on the various panels
        /// </summary>
        private void InitializeAllControls()
        {
            //Initialize the Channel Map panel
            channelMap.InitChannelMapControl(channelMapListView);
            show.InitShowControls(showFilesListView, showSequencesListView, showPauseListViewEx);
            playlist.InitPlaylistControls(playlistDirectoryTreeView, playlistAvailableMP3sListView, playlistMP3sListView);
            schedule.InitilizeScheduleControls(scheduleCalendar);
        }

        /// <summary>
        /// This doesn't work at this time.
        /// </summary>
        private void InitializeNavigationBar()
        {
            NaviBarSettings settings = new NaviBarSettings();

            settings.VisibleButtons = appSettings.numberVisibleButtons;

            settings.Collapsed = false;

            List<NaviBandSetting> bands = new List<NaviBandSetting>();

            NaviBandSetting nbs0 = new NaviBandSetting();

            nbs0.Name = appSettings.band0Name;
            nbs0.Order = 0;
            nbs0.Visible = true;

            bands.Add(nbs0);

            NaviBandSetting nbs1 = new NaviBandSetting();
            nbs1.Name = appSettings.band1Name;
            nbs1.Order = 1;
            nbs1.Visible = true;

            bands.Add(nbs1);

            NaviBandSetting nbs2 = new NaviBandSetting();
            nbs2.Name = appSettings.band2Name;
            nbs2.Order = 2;
            nbs2.Visible = true;

            bands.Add(nbs2);

            NaviBandSetting nbs3 = new NaviBandSetting();
            nbs3.Name = appSettings.band3Name;
            nbs3.Order = 3;
            nbs3.Visible = true;

            bands.Add(nbs3);

            NaviBandSetting nbs4 = new NaviBandSetting();
            nbs4.Name = appSettings.band4Name;
            nbs4.Order = 4;
            nbs4.Visible = true;

            bands.Add(nbs4);

            NaviBandSetting nbs5 = new NaviBandSetting();
            nbs5.Name = appSettings.band5Name;
            nbs5.Order = 5;
            nbs5.Visible = true;

            bands.Add(nbs5);


            settings.BandSettings = bands;

            mainNavigationBar.Settings = settings;
            mainNavigationBar.ApplySettings();
            mainNavigationBar.VisibleLargeButtons = appSettings.numberVisibleButtons;
            mainNavigationBar.ActiveBand = mainNavigationBar.Bands[0];

            //MessageBox.Show(appSettings.band0Name + "\r" + appSettings.band1Name + "\r" +
            //    appSettings.band2Name + "\r" + appSettings.band3Name + "\r" +
            //    appSettings.band4Name + "\r" + appSettings.band5Name + "\r" + 
            //    appSettings.numberVisibleButtons.ToString());

        }

        private void SaveNavigationBarSettings()
        {
            NaviBandCollection bands = mainNavigationBar.Bands;

            appSettings.band0Name = bands[0].Name;
            appSettings.band1Name = bands[1].Name;
            appSettings.band2Name = bands[2].Name;
            appSettings.band3Name = bands[3].Name;
            appSettings.band4Name = bands[4].Name;
            appSettings.band5Name = bands[5].Name;

            appSettings.numberVisibleButtons = mainNavigationBar.VisibleLargeButtons;

            //MessageBox.Show(appSettings.band0Name + "\r" + appSettings.band1Name + "\r" +
            //    appSettings.band2Name + "\r" + appSettings.band3Name + "\r" +
            //    appSettings.band4Name + "\r" + appSettings.band5Name + "\r" +
            //    appSettings.numberVisibleButtons.ToString());
        }

        /// <summary>
        /// Updates the Main Form based upon the current selected Navigation Button
        /// </summary>
        private void UpdateMainForm()
        {
            //Get the text of the currently selected Navigation Band
            string selectedNavigationButtonText = mainNavigationBar.ActiveBand.Text;

            //Hide all of the Panels in the main working area
            HideAllPanels();

            //Hide all of the Status Labels
            HideAllStatusLabels();

            int labelWidth = 0;
            Size labelSize = new Size();

            //Update the main form GUI based upon the current selected navigation band
            switch (selectedNavigationButtonText)
            {
                case "Schedules":
                    //Setup the Title Bar with the Proper Image and Title
                    titleBarImage.ImageIndex = 0;
                    titleBarLabel.Text = schedule.CurrentScheduleFileName;

                    //Refresh the List of Saved Schedules in the Navigation Group
                    schedule.PopulateScheduleListView(savedSchedulesListView);

                    //Make the Schedule Panel the Current Panel
                    schedulePanel.Visible = true;
                    schedulePanel.Dock = DockStyle.Fill;

                    //Update the Menu and Tool Strip to Work with the Schedule
                    mainOpenToolStripButton.Text = "&Open Schedule";
                    mainOpenToolStripMenuItem.Text = "&Open Schedule";
                    mainNewToolStripButton.Text = "&New Schedule";
                    mainNewToolStripMenuItem.Text = "&New Schedule";
                    mainSaveToolStripButton.Text = "&Save Schedule";
                    mainSaveToolStripMenuItem.Text = "&Save Schedule";
                    mainSaveAsToolStripMenuItem.Text = "Save &As Schedule";

                    //Enable the Menu and Tool Strip Items as Necessary
                    if (scheduleCalendar.CalendarNeedsToBeSaved == true)
                    {
                        mainSaveToolStripButton.Enabled = true;
                        mainSaveToolStripMenuItem.Enabled = true;
                    }
                    else
                    {
                        mainSaveToolStripButton.Enabled = false;
                        mainSaveToolStripMenuItem.Enabled = false;
                    }

                    if (scheduleCalendar.Items.Count > 0)
                    {
                        mainSaveAsToolStripMenuItem.Enabled = true;
                    }
                    else
                    {
                        mainSaveAsToolStripMenuItem.Enabled = false;
                    }

                    //Configure and populate the Status Bar

                    labelSize = new Size(50, 17);
                    statusBarLabel1.Size = labelSize;
                    statusBarLabel1.BorderSides = ToolStripStatusLabelBorderSides.None;

                    labelWidth = scheduleCalendar.Size.Width - 130;
                    labelWidth = labelWidth / 7;

                    labelSize = new Size(labelWidth, 17);

                    statusBarLabel2.Size = labelSize;
                    statusBarLabel3.Size = labelSize;
                    statusBarLabel4.Size = labelSize;
                    statusBarLabel5.Size = labelSize;
                    statusBarLabel6.Size = labelSize;
                    statusBarLabel7.Size = labelSize;
                    statusBarLabel8.Size = labelSize;

                    statusBarLabel0.Visible = true;
                    statusBarLabel1.Visible = true;
                    statusBarLabel2.Visible = true;
                    statusBarLabel3.Visible = true;
                    statusBarLabel4.Visible = true;
                    statusBarLabel5.Visible = true;
                    statusBarLabel6.Visible = true;
                    statusBarLabel7.Visible = true;
                    statusBarLabel8.Visible = true;

                    UpdateScheduleLabels();
                    break;

                case "Troubleshooting":
                    titleBarImage.ImageIndex = 1;
                    titleBarLabel.Text = "Troubleshooting";
                    xBeePanel.Dock = DockStyle.Top;
                    xBeePanel.Visible = true;
                    break;

                case "Playlists":
                    //Setup the Title Bar with the Proper Image and Title
                    titleBarImage.ImageIndex = 2;
                    titleBarLabel.Text = "New Playlist"; //Needs to be updated

                    //Refresh the List of Saved Playlists in the Navigation Group
                    playlist.PopulateSavedPlaylistListView(savedPlaylistListView);

                    //Make the Playlist Panel the Current Panel
                    playlistPanel.Visible = true;
                    playlistPanel.Dock = DockStyle.Fill;

                    //Update the Menu and Tool Strip to Work with the Playlist
                    mainOpenToolStripButton.Text = "&Open Playlist";
                    mainOpenToolStripMenuItem.Text = "&Open Playlist";
                    mainNewToolStripButton.Text = "&New Playlist";
                    mainNewToolStripMenuItem.Text = "&New Playlist";
                    mainSaveToolStripButton.Text = "&Save Playlist";
                    mainSaveToolStripMenuItem.Text = "&Save Playlist";
                    mainSaveAsToolStripMenuItem.Text = "Save &As Playlist";

                    //Enable the Menu and Tool Strip Items as Necessary
                    if (playlist.PlayListNeedsToBeSaved == true)
                    {
                        mainSaveToolStripButton.Enabled = true;
                        mainSaveToolStripMenuItem.Enabled = true;
                    }
                    else
                    {
                        mainSaveToolStripButton.Enabled = false;
                        mainSaveToolStripMenuItem.Enabled = false;
                    }

                    if (playlistMP3sListView.Items.Count > 0)
                    {
                        mainSaveAsToolStripMenuItem.Enabled = true;
                    }
                    else
                    {
                        mainSaveAsToolStripMenuItem.Enabled = false;
                    }

                    //Configure and populate the Status Bar

                    labelSize = new Size(200, 17);
                    statusBarLabel1.Size = labelSize;
                    statusBarLabel1.BorderSides = ToolStripStatusLabelBorderSides.All;
                    statusBarLabel2.Size = labelSize;

                    labelWidth = playlistMP3sListView.Size.Width - 10;
                    labelSize = new Size(labelWidth, 17);
                    statusBarLabel3.Size = labelSize;

                    statusBarLabel0.Visible = true;
                    statusBarLabel1.Visible = true;
                    statusBarLabel2.Visible = true;
                    statusBarLabel3.Visible = true;

                    UpdatePlaylistLabels();
                    break;

                case "Settings":
                    titleBarImage.ImageIndex = 3;
                    titleBarLabel.Text = "Settings";
                    xBeePanel.Dock = DockStyle.Top;
                    xBeePanel.Visible = true;
                    break;

                case "Channel Maps":
                    //Setup the Title Bar with the Proper Image and Title
                    titleBarImage.ImageIndex = 4;
                    titleBarLabel.Text = channelMap.CurrentChannelMapFileName;

                    //Refresh the List of Saved Channel Maps in the Navigation Group
                    channelMap.PopulateSavedChannelMapListView(savedChannelMapListView);

                    //Make the Channel Map Panel the Current Panel
                    channelMapPanel.Visible = true;
                    channelMapPanel.Dock = DockStyle.Fill;

                    //Update the Menu and Tool Strip to Work with the Channel Map
                    mainOpenToolStripButton.Text = "&Open Channel Map";
                    mainOpenToolStripMenuItem.Text = "&Open Channel Map";
                    mainNewToolStripButton.Text = "&New Channel Map";
                    mainNewToolStripMenuItem.Text = "&New Channel Map";
                    mainSaveToolStripButton.Text = "&Save Channel Map";
                    mainSaveToolStripMenuItem.Text = "&Save Channel Map";
                    mainSaveAsToolStripMenuItem.Text = "Save &As Channel Map";

                    //Enable the Menu and Tool Strip Items as Necessary
                    if (channelMap.ChannelMapNeedsToBeSaved == true)
                    {
                        mainSaveToolStripButton.Enabled = true;
                        mainSaveToolStripMenuItem.Enabled = true;
                    }
                    else
                    {
                        mainSaveToolStripButton.Enabled = false;
                        mainSaveToolStripMenuItem.Enabled = false;
                    }

                    if (channelMap.NumberOfHelixSystems > 0)
                    {
                        mainSaveAsToolStripMenuItem.Enabled = true;
                    }
                    else
                    {
                        mainSaveAsToolStripMenuItem.Enabled = false;
                    }
                    break;

                case "Shows":
                    //Setup the Title Bar with the Proper Image and Title
                    titleBarImage.ImageIndex = 5;
                    titleBarLabel.Text = show.CurrentShowFileName;

                    //Refresh the List of Saved Shows in the Navigation Group
                    show.PopulateSavedShowListView(savedShowListView);

                    //Make the Shows Panel the Current Panel
                    showPanel.Visible = true;
                    showPanel.Dock = DockStyle.Fill;

                    //Update the Menu and Tool Strip to Work with the Shows
                    mainOpenToolStripButton.Text = "&Open Show";
                    mainOpenToolStripMenuItem.Text = "&Open Show";
                    mainNewToolStripButton.Text = "&New Show";
                    mainNewToolStripMenuItem.Text = "&New Show";
                    mainSaveToolStripButton.Text = "&Save Show";
                    mainSaveToolStripMenuItem.Text = "&Save Show";
                    mainSaveAsToolStripMenuItem.Text = "Save &As Show";

                    //Enable the Menu and Tool Strip Items as Necessary
                    if (show.ShowNeedsToBeSaved == true)
                    {
                        mainSaveToolStripButton.Enabled = true;
                        mainSaveToolStripMenuItem.Enabled = true;
                    }
                    else
                    {
                        mainSaveToolStripButton.Enabled = false;
                        mainSaveToolStripMenuItem.Enabled = false;
                    }

                    if (showSequencesListView.Items.Count > 0)
                    {
                        mainSaveAsToolStripMenuItem.Enabled = true;
                    }
                    else
                    {
                        mainSaveAsToolStripMenuItem.Enabled = false;
                    }

                    //Configure and populate the Status Bar

                    labelSize = new Size(200, 17);
                    statusBarLabel1.Size = labelSize;
                    statusBarLabel1.BorderSides = ToolStripStatusLabelBorderSides.All;

                    labelWidth = showSequencesListView.Size.Width - 10;
                    labelSize = new Size(labelWidth, 17);
                    statusBarLabel2.Size = labelSize;

                    statusBarLabel0.Visible = true;
                    statusBarLabel1.Visible = true;
                    statusBarLabel2.Visible = true;
                    
                    UpdateShowLabels();
                    break;
            }//end switch
        }//end UpdateMainForm

        /// <summary>
        /// Hide all of the Panels on the Main Form
        /// </summary>
        private void HideAllPanels()
        {
            channelMapPanel.Visible = false;
            showPanel.Visible = false;
            playlistPanel.Visible = false;
            schedulePanel.Visible = false;
            xBeePanel.Visible = false;
        }

        private void HideAllStatusLabels()
        {
            statusBarLabel0.Visible = false;
            statusBarLabel1.Visible = false;
            statusBarLabel2.Visible = false;
            statusBarLabel3.Visible = false;
            statusBarLabel4.Visible = false;
            statusBarLabel5.Visible = false;
            statusBarLabel6.Visible = false;
            statusBarLabel7.Visible = false;
            statusBarLabel8.Visible = false;
        }

        /// <summary>
        /// Save the various Helix Objects
        /// </summary>
        private void SaveHelixObjects()
        {
            string activeNavigationBand = mainNavigationBar.ActiveBand.Text;

            switch (activeNavigationBand)
            {
                case "Channel Maps":
                    //Try to save the current Channel Map
                    if (channelMap.SaveChannelMap(channelMapListView) == true)
                    {
                        //Update the Saved Channel Map List View
                        channelMap.PopulateSavedChannelMapListView(savedChannelMapListView);

                        //Update the Main Form Title Bar
                        titleBarLabel.Text = channelMap.CurrentChannelMapFileName;

                        //Update the Menu and Tool Bar
                        mainSaveToolStripButton.Enabled = false;
                        mainSaveToolStripMenuItem.Enabled = false;
                    }
                    else
                    {
                        MessageBox.Show("Error Saving Channel Map");
                    }
                    break;

                case "Shows":
                    //Try to save the current Show
                    if (show.SaveShowFile(showSequencesListView) == true)
                    {
                        //Update the Saved Show List View
                        show.PopulateSavedShowListView(savedShowListView);

                        //Update the Main Form Title Bar
                        titleBarLabel.Text = show.CurrentShowFileName;

                        //Update the Menu and Tool Bar
                        mainSaveToolStripButton.Enabled = false;
                        mainSaveToolStripMenuItem.Enabled = false;
                        UpdateShowLabels();
                    }
                    else
                    {
                        MessageBox.Show("Error Saving Show");
                    }
                    break;

                case "Playlists":
                    //Try to save the current Playlist
                    if (playlist.SavePlaylistFile(playlistMP3sListView) == true)
                    {
                        //Update the Saved Playlist List View
                        playlist.PopulateSavedPlaylistListView(savedPlaylistListView);

                        //Update the Main Form Title Bar
                        titleBarLabel.Text = playlist.CurrentPlaylistFileName;

                        //Update the Menu and Tool Bar
                        mainSaveToolStripButton.Enabled = false;
                        mainSaveToolStripMenuItem.Enabled = false;
                        UpdatePlaylistLabels();
                    }
                    else
                    {
                        MessageBox.Show("Error Saving Playlist");
                    }
                    break;

                case "Schedules":
                    //Try to save the current Schedule
                    if (schedule.SaveSchedule(scheduleCalendar) == true)
                    {
                        //Update the Saved Playlist List View
                        schedule.PopulateScheduleListView(savedSchedulesListView);

                        //Update the Main Form Title Bar
                        titleBarLabel.Text = schedule.CurrentScheduleFileName;

                        //Update the Menu and Tool Bar
                        mainSaveToolStripButton.Enabled = false;
                        mainSaveToolStripMenuItem.Enabled = false;
                        UpdateScheduleLabels();
                    }
                    else
                    {
                        MessageBox.Show("Error Saving Schedule");
                    }
                    break;

                default:
                    MessageBox.Show("This Feature Isn't Implemented Yet");
                    break;
            }//end Switch
        }//end SaveHelixObject

        /// <summary>
        /// Create a New Helix Object
        /// </summary>
        private void NewHelixObject()
        {
            string activeNavigationBand = mainNavigationBar.ActiveBand.Text;

            switch (activeNavigationBand)
            {
                case "Channel Maps":
                    //Try to Create a New Channel Map
                    if (channelMap.NewChannelMap(channelMapListView) == true)
                    {
                        //Update the Main Form Title Bar
                        titleBarLabel.Text = channelMap.CurrentChannelMapFileName;

                        //Update the Buttons, Menu and Tool Bar Items
                        mainSaveToolStripButton.Enabled = false;
                        mainSaveToolStripMenuItem.Enabled = false;
                        mainSaveAsToolStripMenuItem.Enabled = false;
                        channelMapEditHelixSystemButton.Enabled = false;
                        channelMapDeleteHelixSystemButton.Enabled = false;
                    }
                    break;

                case "Shows":
                    //Try to Create a New Show
                    if (show.NewShow(showSequencesListView) == true)
                    {
                        //Update the Main Form Title Bar
                        titleBarLabel.Text = show.CurrentShowFileName;

                        //Update the Buttons, Menu and Tool Bar Items
                        mainSaveToolStripButton.Enabled = false;
                        mainSaveToolStripMenuItem.Enabled = false;
                        mainSaveAsToolStripMenuItem.Enabled = false;
                        UpdateShowLabels();
                    }
                    break;

                case "Playlists":
                    //Try to Create a New Show
                    if (playlist.NewPlaylist(playlistMP3sListView) == true)
                    {
                        //Update the Main Form Title Bar
                        titleBarLabel.Text = playlist.CurrentPlaylistFileName;

                        //Update the Buttons, Menu and Tool Bar Items
                        mainSaveToolStripButton.Enabled = false;
                        mainSaveToolStripMenuItem.Enabled = false;
                        mainSaveAsToolStripMenuItem.Enabled = false;
                        UpdatePlaylistLabels();
                    }
                    break;

                case "Schedules":
                    //Try to Create a New Schedule
                    if (schedule.NewSchedule(scheduleCalendar) == true)
                    {
                        //Update the Main Form Title Bar
                        titleBarLabel.Text = schedule.CurrentScheduleFileName;

                        //Update the Buttons, Menu and Tool Bar Items
                        mainSaveToolStripButton.Enabled = false;
                        mainSaveToolStripMenuItem.Enabled = false;
                        mainSaveAsToolStripMenuItem.Enabled = false;
                        UpdateScheduleLabels();
                    }
                    break;

                default:
                    {
                        MessageBox.Show("This feature isn't implemented yet.");
                    }
                    break;
            }//end switch
        }

        /// <summary>
        /// Open an Existing Helix Object
        /// </summary>
        private void OpenHelixObject()
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            //Get the text of the currently selected Navigation Band
            string selectedNavigationButtonText = mainNavigationBar.ActiveBand.Text;

            switch (selectedNavigationButtonText)
            {
                case "Channel Maps":
                    openFileDialog.DefaultExt = "map";
                    openFileDialog.InitialDirectory = appSettings.channelMapFilePath;
                    openFileDialog.Filter = "Helix Channel Maps|*.map";
                    openFileDialog.FileName = "";

                    if (openFileDialog.ShowDialog() == DialogResult.OK)
                    {
                        if (channelMap.OpenChannelMap(channelMapListView, openFileDialog.FileName) == true)
                        {
                            mainSaveAsToolStripMenuItem.Enabled = true;
                            channelMapEditHelixSystemButton.Enabled = true;
                            channelMapDeleteHelixSystemButton.Enabled = true;
                        }
                        else
                        {
                            mainSaveAsToolStripMenuItem.Enabled = false;
                            channelMapEditHelixSystemButton.Enabled = false;
                            channelMapDeleteHelixSystemButton.Enabled = false;                            
                        }
                        mainSaveToolStripButton.Enabled = false;
                        mainSaveToolStripMenuItem.Enabled = false;
                        titleBarLabel.Text = channelMap.CurrentChannelMapFileName;
                    }
                    break;

                case "Shows":
                    openFileDialog.DefaultExt = "shw";
                    openFileDialog.InitialDirectory = appSettings.showFilePath;
                    openFileDialog.Filter = "Helix Shows|*.shw";
                    openFileDialog.FileName = "";

                    if (openFileDialog.ShowDialog() == DialogResult.OK)
                    {
                        if (show.OpenShowFile(showSequencesListView, openFileDialog.FileName) == true)
                        {
                            mainSaveAsToolStripMenuItem.Enabled = true;
                        }
                        else
                        {
                            mainSaveAsToolStripMenuItem.Enabled = false;
                        }
                        mainSaveToolStripButton.Enabled = false;
                        mainSaveToolStripMenuItem.Enabled = false;
                        titleBarLabel.Text = show.CurrentShowFileName;
                        UpdateShowLabels();
                    }
                    break;

                case "Playlists":
                    openFileDialog.DefaultExt = "ply";
                    openFileDialog.InitialDirectory = appSettings.playlistFilePath;
                    openFileDialog.Filter = "Helix Playlists|*.ply";
                    openFileDialog.FileName = "";

                    if (openFileDialog.ShowDialog() == DialogResult.OK)
                    {
                        if (playlist.OpenPlaylistFile(playlistMP3sListView,openFileDialog.FileName) == true)
                        {
                            mainSaveAsToolStripMenuItem.Enabled = true;
                        }
                        else
                        {
                            mainSaveAsToolStripMenuItem.Enabled = false;
                        }
                        mainSaveToolStripButton.Enabled = false;
                        mainSaveToolStripMenuItem.Enabled = false;
                        titleBarLabel.Text = playlist.CurrentPlaylistFileName;
                        UpdatePlaylistLabels();
                    }
                    break;

                case "Schedules":
                    openFileDialog.DefaultExt = "sch";
                    openFileDialog.InitialDirectory = appSettings.scheduleFilePath;
                    openFileDialog.Filter = "Helix Schedules|*.sch";
                    openFileDialog.FileName = "";

                    if (openFileDialog.ShowDialog() == DialogResult.OK)
                    {
                        if (schedule.OpenSchedule(scheduleCalendar, openFileDialog.FileName) == true)
                        {
                            mainSaveAsToolStripMenuItem.Enabled = true;
                        }
                        else
                        {
                            mainSaveAsToolStripMenuItem.Enabled = false;
                        }
                        mainSaveToolStripButton.Enabled = false;
                        mainSaveToolStripMenuItem.Enabled = false;
                        titleBarLabel.Text = schedule.CurrentScheduleFileName;
                        UpdateScheduleLabels();
                    }
                    break;

                default:
                    MessageBox.Show("This feature isn't implemented yet");
                    break;
            }
        }

        /// <summary>
        /// Delete an Existing Helix Object
        /// </summary>
        /// <param name="deleteFileFullPath"></param>
        /// <param name="deleteFileOpen"></param>
        private void DeleteHelixObject(string deleteFileFullPath, bool deleteFileOpen)
        {
            if (deleteFileOpen)
            {
                MessageBox.Show(Path.GetFileName(deleteFileFullPath) + " is currently open and cannot be deleted.",
                     "Delete Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                DialogResult dR = MessageBox.Show("Are you sure you want to permanently delete file:  " + 
                    Path.GetFileName(deleteFileFullPath), "Helix Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                if (dR == DialogResult.Yes)
                {
                    File.Delete(deleteFileFullPath);
                }
            }
        }

        private void UpdatePlaylistLabels()
        {

            if (playlist.PlayListNeedsToBeSaved == true)
            {
                statusBarLabel0.Text = "Playlist Needs To Be Saved";
                statusBarLabel0.BackColor = Color.Yellow;
            }
            else
            {
                statusBarLabel0.Text = "Playlist Doesn't Need To Be Saved";
                statusBarLabel0.BackColor = Color.LightGreen;
            }

            statusBarLabel1.Text = "Folders";

            statusBarLabel2.Text = "Available MP3s:  " + playlist.NumberOfMP3sAvailable.ToString();

            statusBarLabel3.Text = "Total Songs:  " + playlist.NumberOfSongsInPlaylist.ToString() +
                "   Total Length:  " + playlist.FormatedLengtOfPlaylist + "   Total Size:  " + playlist.FormatedSizeOfPlaylist;
        }

        private void UpdateShowLabels()
        {
            if (show.ShowNeedsToBeSaved == true)
            {
                statusBarLabel0.Text = "Show Needs To Be Saved";
                statusBarLabel0.BackColor = Color.Yellow;
            }
            else
            {
                statusBarLabel0.Text = "Show Doesn't Need To Be Saved";
                statusBarLabel0.BackColor = Color.LightGreen;
            }

            statusBarLabel1.Text = "Available Shows:  " + show.NumberOfAvailableSequences;

            statusBarLabel2.Text = "Total Sequences:  " + show.NumberOfSequencesInShow.ToString() +
                "   Total Length:  " + show.FormatedTotalLength + "   Total Size:  " + show.FormatedTotalSize +
                "   Max # of Channels:  " + show.MaximumNumberOfChannels.ToString();
        }

        private void UpdateScheduleLabels()
        {
            if (scheduleCalendar.CalendarNeedsToBeSaved == true)
            {
                statusBarLabel0.Text = "Schedule Needs To Be Saved";
                statusBarLabel0.BackColor = Color.Yellow;
            }
            else
            {
                statusBarLabel0.Text = "Schedule Doesn't Need To Be Saved";
                statusBarLabel0.BackColor = Color.LightGreen;
            }

            statusBarLabel1.Text = "";

            int itemCount = scheduleCalendar.ItemsPerDay(0);
            statusBarLabel2.Text = "Item Count:  " + itemCount.ToString();
            if (itemCount > 9)
            {
                statusBarLabel2.BackColor = Color.Red;
                statusBarLabel2.ForeColor = Color.White;
            }
            else if (itemCount == 9)
            {
                statusBarLabel2.BackColor = Color.Yellow;
                statusBarLabel2.ForeColor = Color.Black;
            }
            else
            {
                statusBarLabel2.BackColor = Color.Transparent;
                statusBarLabel2.ForeColor = Color.Black;
            }

            itemCount = scheduleCalendar.ItemsPerDay(1);
            statusBarLabel3.Text = "Item Count:  " + itemCount.ToString();
            if (itemCount > 9)
            {
                statusBarLabel3.BackColor = Color.Red;
                statusBarLabel3.ForeColor = Color.White;
            }
            else if (itemCount == 9)
            {
                statusBarLabel3.BackColor = Color.Yellow;
                statusBarLabel3.ForeColor = Color.Black;
            }
            else
            {
                statusBarLabel3.BackColor = Color.Transparent;
                statusBarLabel3.ForeColor = Color.Black;
            }

            itemCount = scheduleCalendar.ItemsPerDay(2);
            statusBarLabel4.Text = "Item Count:  " + itemCount.ToString();
            if (itemCount > 9)
            {
                statusBarLabel4.BackColor = Color.Red;
                statusBarLabel4.ForeColor = Color.White;
            }
            else if (itemCount == 9)
            {
                statusBarLabel4.BackColor = Color.Yellow;
                statusBarLabel4.ForeColor = Color.Black;
            }
            else
            {
                statusBarLabel4.BackColor = Color.Transparent;
                statusBarLabel4.ForeColor = Color.Black;
            }

            itemCount = scheduleCalendar.ItemsPerDay(3);
            statusBarLabel5.Text = "Item Count:  " + itemCount.ToString();
            if (itemCount > 9)
            {
                statusBarLabel5.BackColor = Color.Red;
                statusBarLabel5.ForeColor = Color.White;
            }
            else if (itemCount == 9)
            {
                statusBarLabel5.BackColor = Color.Yellow;
                statusBarLabel5.ForeColor = Color.Black;
            }
            else
            {
                statusBarLabel5.BackColor = Color.Transparent;
                statusBarLabel5.ForeColor = Color.Black;
            }

            itemCount = scheduleCalendar.ItemsPerDay(4);
            statusBarLabel6.Text = "Item Count:  " + itemCount.ToString();
            if (itemCount > 9)
            {
                statusBarLabel6.BackColor = Color.Red;
                statusBarLabel6.ForeColor = Color.White;
            }
            else if (itemCount == 9)
            {
                statusBarLabel6.BackColor = Color.Yellow;
                statusBarLabel6.ForeColor = Color.Black;
            }
            else
            {
                statusBarLabel6.BackColor = Color.Transparent;
                statusBarLabel6.ForeColor = Color.Black;
            }

            itemCount = scheduleCalendar.ItemsPerDay(5);
            statusBarLabel7.Text = "Item Count:  " + itemCount.ToString();
            if (itemCount > 9)
            {
                statusBarLabel7.BackColor = Color.Red;
                statusBarLabel7.ForeColor = Color.White;
            }
            else if (itemCount == 9)
            {
                statusBarLabel7.BackColor = Color.Yellow;
                statusBarLabel7.ForeColor = Color.Black;
            }
            else
            {
                statusBarLabel7.BackColor = Color.Transparent;
                statusBarLabel7.ForeColor = Color.Black;
            }

            itemCount = scheduleCalendar.ItemsPerDay(6);
            statusBarLabel8.Text = "Item Count:  " + itemCount.ToString();
            if (itemCount > 9)
            {
                statusBarLabel8.BackColor = Color.Red;
                statusBarLabel8.ForeColor = Color.White;
            }
            else if (itemCount == 9)
            {
                statusBarLabel8.BackColor = Color.Yellow;
                statusBarLabel8.ForeColor = Color.Black;
            }
            else
            {
                statusBarLabel8.BackColor = Color.Transparent;
                statusBarLabel8.ForeColor = Color.Black;
            }

        }

        #endregion Private Methods

        #region Events

            #region Navigation Bar Events

            private void mainNavigationBar_ActiveBandChanged(object sender, EventArgs e)
            {
                UpdateMainForm();
            }

            #endregion Navigation Bar Events

            #region Show Events

            /// <summary>
            /// Open a the Selected Show
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void savedShowListView_DoubleClick(object sender, EventArgs e)
            {
                ListView.SelectedListViewItemCollection selectedFile = savedShowListView.SelectedItems;

                ListViewItem.ListViewSubItemCollection fileParts = selectedFile[0].SubItems;

                string openShowFilePath = fileParts[1].Text + @"\" + fileParts[0].Text;

                if (show.OpenShowFile(showSequencesListView, openShowFilePath) == true)
                {
                    mainSaveAsToolStripMenuItem.Enabled = true;
                }
                else
                {
                    mainSaveAsToolStripMenuItem.Enabled = false;
                }

                titleBarLabel.Text = show.CurrentShowFileName;
                mainSaveToolStripButton.Enabled = false;
                mainSaveToolStripMenuItem.Enabled = false;
                UpdateShowLabels();
            }

            /// <summary>
            /// Add the Selected Sequence to the Show
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void showFilesListView_DoubleClick(object sender, EventArgs e)
            {
                ListViewItem selectedFile = show.GetSelectedVixenSequence(showFilesListView);
                int targetIndex = showSequencesListView.Items.Count;
                if (show.AddSequenceToShow(showSequencesListView,selectedFile,targetIndex) == true)
                {
                    mainSaveToolStripButton.Enabled = true;
                    mainSaveToolStripMenuItem.Enabled = true;
                    mainSaveAsToolStripMenuItem.Enabled = true;
                    UpdateShowLabels();
                }
            }

            /// <summary>
            /// Delete the Selected Sequence or Pause from the Show
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void showSequencesListView_DoubleClick(object sender, EventArgs e)
            {
                if (show.DeleteSequenceFromShow(showSequencesListView) == true)
                {
                    if (show.NumberOfSequencesInShow == 0)
                    {
                        mainSaveToolStripButton.Enabled = false;
                        mainSaveToolStripMenuItem.Enabled = false;
                        mainSaveAsToolStripMenuItem.Enabled = false;
                    }
                    else
                    {
                        mainSaveToolStripButton.Enabled = true;
                        mainSaveToolStripMenuItem.Enabled = true;
                        show.CheckForPauseError(showSequencesListView);
                    }
                    UpdateShowLabels();
                }
            }

            /// <summary>
            /// Start to Drag & Drop an Item from the Show Files List View
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void showFilesListView_ItemDrag(object sender, ItemDragEventArgs e)
            {
                ListViewItem dragItem = show.GetSelectedVixenSequence(showFilesListView);

                showFilesListView.DoDragDrop(dragItem, DragDropEffects.Copy);
            }

            /// <summary>
            /// Allow and Item to Dragged into the Show Sequence List View
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void showSequencesListView_DragEnter(object sender, DragEventArgs e)
            {
                e.Effect = e.AllowedEffect;
            }

            /// <summary>
            /// If Dragging Over the Show Sequences List View then Show the Insertion Mark
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void showSequencesListView_DragOver(object sender, DragEventArgs e)
            {
                // Retrieve the client coordinates of the mouse pointer.
                Point targetPoint =
                    showSequencesListView.PointToClient(new Point(e.X, e.Y));

                // Retrieve the index of the item closest to the mouse pointer.
                int targetIndex = showSequencesListView.InsertionMark.NearestIndex(targetPoint);

                // Confirm that the mouse pointer is not over the dragged item.
                if (targetIndex > -1)
                {
                    // Determine whether the mouse pointer is to the left or
                    // the right of the midpoint of the closest item and set
                    // the InsertionMark.AppearsAfterItem property accordingly.
                    Rectangle itemBounds = showSequencesListView.GetItemRect(targetIndex);
                    if (targetPoint.Y > itemBounds.Top + (itemBounds.Height / 2))
                    {
                        showSequencesListView.InsertionMark.AppearsAfterItem = true;
                    }
                    else
                    {
                        showSequencesListView.InsertionMark.AppearsAfterItem = false;
                    }
                }

                // Set the location of the insertion mark. If the mouse is
                // over the dragged item, the targetIndex value is -1 and
                // the insertion mark disappears.
                showSequencesListView.InsertionMark.Index = targetIndex;
            }

            /// <summary>
            /// If Not Dragging Over the Show Sequence List View then Clear the Insertion Mark
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void showSequencesListView_DragLeave(object sender, EventArgs e)
            {
                showSequencesListView.InsertionMark.Index = -1;
            }

            /// <summary>
            /// Drop the Selected Item into the Show Sequences List View
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void showSequencesListView_DragDrop(object sender, DragEventArgs e)
            {
                // Retrieve the index of the insertion mark;
                int targetIndex = showSequencesListView.InsertionMark.Index;


                // If the insertion mark is to the bottom of the item with
                // the corresponding index, increment the target index.
                if (showSequencesListView.InsertionMark.AppearsAfterItem)
                {
                    targetIndex++;
                }

                ListViewItem draggedItem = (ListViewItem)e.Data.GetData(typeof(ListViewItem));

                if (draggedItem.SubItems[0].Text == "Error")
                {
                    //Error Item
                    return;
                }

                if (draggedItem.SubItems[0].Text == "Pause")
                {
                    show.AddPauseToShow(showSequencesListView, draggedItem, targetIndex);
                }

                else
                {
                    show.AddSequenceToShow(showSequencesListView, draggedItem, targetIndex);
                }

                mainSaveToolStripButton.Enabled = true;
                mainSaveToolStripMenuItem.Enabled = true;
                mainSaveAsToolStripMenuItem.Enabled = true;
                show.CheckForPauseError(showSequencesListView);
                UpdateShowLabels();
            }

            /// <summary>
            /// Start to Drag & Drop an Item from the Show Sequences List View
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void showSequencesListView_ItemDrag(object sender, ItemDragEventArgs e)
            {
                ListViewItem dragItem = show.GetSelectedShowItem(showSequencesListView);

                showSequencesListView.DoDragDrop(dragItem, DragDropEffects.Move);
            }

            /// <summary>
            /// Allow an Item to Dragged into the Show Files List View
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void showFilesListView_DragEnter(object sender, DragEventArgs e)
            {
                ListViewItem draggedItem = (ListViewItem)e.Data.GetData(typeof(ListViewItem));

                if (draggedItem.SubItems[2].Text == "showSequencesListView")
                {
                    e.Effect = e.AllowedEffect;
                }
                else
                {
                    e.Effect = DragDropEffects.None; 
                }
            }

            /// <summary>
            /// Delete the Selected Show Item from the Show Sequence List View
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void showFilesListView_DragDrop(object sender, DragEventArgs e)
            {
                ListViewItem draggedItem = (ListViewItem)e.Data.GetData(typeof(ListViewItem));

                if (draggedItem.SubItems[2].Text != "showSequencesListView")
                {
                    return;
                }

                if (show.DeleteSequenceFromShow(showSequencesListView) == true)
                {
                    if (show.NumberOfSequencesInShow == 0)
                    {
                        mainSaveToolStripButton.Enabled = false;
                        mainSaveToolStripMenuItem.Enabled = false;
                        mainSaveAsToolStripMenuItem.Enabled = false;
                    }
                    else
                    {
                        mainSaveToolStripButton.Enabled = true;
                        mainSaveToolStripMenuItem.Enabled = true;
                        show.CheckForPauseError(showSequencesListView);
                    }
                    UpdateShowLabels();
                }
            }

            /// <summary>
            /// Start Dragging a Pause into the Show Sequences List View
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void showPauseListViewEx_ItemDrag(object sender, ItemDragEventArgs e)
            {
                ListViewItem dragItem = show.GetSelectedPauseItem(showPauseListViewEx);

                showPauseListViewEx.DoDragDrop(dragItem, DragDropEffects.Move);
            }

            /// <summary>
            /// Add a the Selected Pause from the Show Pause List View to the Show Sequences List View
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void showPauseListViewEx_MouseDoubleClick(object sender, MouseEventArgs e)
            {
                ListViewItem pauseItem = show.GetSelectedPauseItem(showPauseListViewEx);
                int targetIndex = showSequencesListView.Items.Count;

                if (show.AddPauseToShow(showSequencesListView, pauseItem, targetIndex) == true)
                {
                    mainSaveToolStripButton.Enabled = true;
                    mainSaveToolStripMenuItem.Enabled = true;
                    mainSaveAsToolStripMenuItem.Enabled = true;
                    show.CheckForPauseError(showSequencesListView);
                    UpdateShowLabels();
                }
            }

            /// <summary>
            /// Allow an Item to be Dropped In the Show Pause List View
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void showPauseListViewEx_DragEnter(object sender, DragEventArgs e)
            {
                ListViewItem draggedItem = (ListViewItem)e.Data.GetData(typeof(ListViewItem));

                if (draggedItem.SubItems[2].Text == "showSequencesListView")
                {
                    e.Effect = e.AllowedEffect;
                }
                else
                {
                    e.Effect = DragDropEffects.None; 
                }
            }

            /// <summary>
            /// Delete the Selected Item From the Show Sequences List View
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void showPauseListViewEx_DragDrop(object sender, DragEventArgs e)
            {
                ListViewItem draggedItem = (ListViewItem)e.Data.GetData(typeof(ListViewItem));

                if (draggedItem.SubItems[2].Text != "showSequencesListView")
                {
                    return;
                }

                if (show.DeleteSequenceFromShow(showSequencesListView) == true)
                {
                    if (show.NumberOfSequencesInShow == 0)
                    {
                        mainSaveToolStripButton.Enabled = false;
                        mainSaveToolStripMenuItem.Enabled = false;
                        mainSaveAsToolStripMenuItem.Enabled = false;
                    }
                    else
                    {
                        mainSaveToolStripButton.Enabled = true;
                        mainSaveToolStripMenuItem.Enabled = true;
                        show.CheckForPauseError(showSequencesListView);
                    }
                    UpdateShowLabels();
                }
            }

            /// <summary>
            /// Start Editing a SubItem
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void showPauseListViewEx_SubItemClicked(object sender, ListViewEx.SubItemEventArgs e)
            {
                showPauseListViewEx.StartEditing(Editors[e.SubItem], e.Item, e.SubItem);
            }

            /// <summary>
            /// Saves the Changes to the Application Settings for Future Use
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void showPauseListViewEx_SubItemEndEditing(object sender, ListViewEx.SubItemEndEditingEventArgs e)
            {
                if (e.SubItem == 0)
                {
                    appSettings.SavePauseName(e.Item.Index, e.DisplayText);
                }
                else if (e.SubItem == 1)
                {
                    appSettings.SavePauseLength(e.Item.Index, e.DisplayText);
                }
            }

            /// <summary>
            /// Edit a Show Pause ListViewEx SubItem
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void editPauseMenuItem_Click(object sender, EventArgs e)
            {
                ListViewItem Item;

                Point P = showPauseListViewEx.location;

                int SubItem = showPauseListViewEx.GetSubItemAt(P.X, P.Y, out Item);

                showPauseListViewEx.StartEditing(Editors[SubItem], Item, SubItem);
            }

            /// <summary>
            /// Add the Selected Pause the End of the Current Show
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void addPauseToShow_Click(object sender, EventArgs e)
            {
                ListViewItem pauseItem = show.GetSelectedPauseItem(showPauseListViewEx);
                int targetIndex = showSequencesListView.Items.Count;

                if (show.AddPauseToShow(showSequencesListView, pauseItem, targetIndex) == true)
                {
                    mainSaveToolStripButton.Enabled = true;
                    mainSaveToolStripMenuItem.Enabled = true;
                    mainSaveAsToolStripMenuItem.Enabled = true;
                    show.CheckForPauseError(showSequencesListView);
                    UpdateShowLabels();
                }
            }

            #endregion Show Events

            #region Channel Map Events

            /// <summary>
            /// Try to Open the Selected Channel Map
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void savedChannelMapListView_DoubleClick(object sender, EventArgs e)
            {
                ListView.SelectedListViewItemCollection selectedFile = savedChannelMapListView.SelectedItems;

                ListViewItem.ListViewSubItemCollection fileParts = selectedFile[0].SubItems;

                string openChannelMapFilePath = fileParts[1].Text + @"\" + fileParts[0].Text;
                if (channelMap.OpenChannelMap(channelMapListView, openChannelMapFilePath) == true)
                {
                    mainSaveAsToolStripMenuItem.Enabled = true;
                    channelMapEditHelixSystemButton.Enabled = false;
                    channelMapDeleteHelixSystemButton.Enabled = true;
                }
                else
                {
                    mainSaveAsToolStripMenuItem.Enabled = false;
                    channelMapEditHelixSystemButton.Enabled = false;
                    channelMapDeleteHelixSystemButton.Enabled = false;
                }

                titleBarLabel.Text = channelMap.CurrentChannelMapFileName;
                mainSaveToolStripButton.Enabled = false;
                mainSaveToolStripMenuItem.Enabled = false;

            }

            /// <summary>
            /// Add a Helix System to the Current Channel Map
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void channelMapAddHelixSystemButton_Click(object sender, EventArgs e)
            {
                //Add a Helix System
                channelMap.addHelixSystem(channelMapListView);

                //Enable the Buttons, Menu and Tool Bar Items as Necessary
                if (channelMap.NumberOfHelixSystems > 0)
                {
                    //channelMapEditHelixSystemButton.Enabled = true;
                    channelMapDeleteHelixSystemButton.Enabled = true;
                    mainSaveToolStripButton.Enabled = true;
                    mainSaveToolStripMenuItem.Enabled = true;
                    mainSaveAsToolStripMenuItem.Enabled = true;
                }
            }//end addHelixSystemButton_Click

            /// <summary>
            /// Delete the Last Helix System in the Channel Map
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void channelMapDeleteHelixSystemButton_Click(object sender, EventArgs e)
            {
                //Delete Helix System
                channelMap.deleteHelixSystem(channelMapListView);

                //Disable/Enable the Buttons, Menu and Tool Bar Items as Necessary
                if (channelMap.NumberOfHelixSystems == 0)
                {
                    channelMapEditHelixSystemButton.Enabled = false;
                    channelMapDeleteHelixSystemButton.Enabled = false;
                    mainSaveToolStripButton.Enabled = false;
                    mainSaveToolStripMenuItem.Enabled = false;
                    mainSaveAsToolStripMenuItem.Enabled = false;
                }
                else
                {
                    mainSaveToolStripButton.Enabled = true;
                    mainSaveToolStripMenuItem.Enabled = true;
                    mainSaveAsToolStripMenuItem.Enabled = true;
                }
            }//end deleteHelixSystemButton_Click

            /// <summary>
            /// Edit the selected item
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void channelMapEditHelixSystemButton_Click(object sender, EventArgs e)
            {
                channelMap.editHelixSystem(channelMapListView);
                channelMapEditHelixSystemButton.Enabled = false;
            }

            /// <summary>
            /// Enable the Edit button if a Helix System is Selected
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void channelMapListView_MouseUp(object sender, MouseEventArgs e)
            {
                ListView.SelectedListViewItemCollection itemCollection = channelMapListView.SelectedItems;

                if (itemCollection.Count > 0)
                {
                    channelMapEditHelixSystemButton.Enabled = true;
                }
                else
                {
                    channelMapEditHelixSystemButton.Enabled = false;
                }
            }

            #endregion Channel Map Events

            #region Playlist Events

            /// <summary>
            /// Populate the Folders in the Playlist Directory Tree View
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void playlistDirectoryTreeView_BeforeExpand(object sender, TreeViewCancelEventArgs e)
            {
                playlist.PopulatePlaylistDirectoryTreeViewFolders(e.Node, playlistDirectoryTreeView, playlistAvailableMP3sListView);
            }

            /// <summary>
            /// Populate the Playlist Available MP3s Tree View with the MP3s in the Selected Folder
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void playlistDirectoryTreeView_AfterSelect(object sender, TreeViewEventArgs e)
            {
                playlist.PopulatePlayListAvailableMP3sListView(e.Node, playlistAvailableMP3sListView);
                e.Node.EnsureVisible();
            }

            /// <summary>
            /// Add the Selected MP3 to the Playlist MP3s List View
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void playlistAvailableMP3sListView_MouseDoubleClick(object sender, MouseEventArgs e)
            {
                ListViewItem selectedFile = playlist.GetSelectedSong(playlistAvailableMP3sListView);
                int targetIndex = playlistMP3sListView.Items.Count;
                if (playlist.AddSongToPlaylist(playlistMP3sListView, selectedFile, targetIndex) == true)
                {
                    mainSaveToolStripButton.Enabled = true;
                    mainSaveToolStripMenuItem.Enabled = true;
                    mainSaveAsToolStripMenuItem.Enabled = true;
                    UpdatePlaylistLabels();
                }
            }

            /// <summary>
            /// Open the Selected Playlist
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void savedPlaylistListView_MouseDoubleClick(object sender, MouseEventArgs e)
            {
                ListView.SelectedListViewItemCollection selectedFile = savedPlaylistListView.SelectedItems;

                ListViewItem.ListViewSubItemCollection fileParts = selectedFile[0].SubItems;

                string openPlaylistFilePath = fileParts[1].Text + @"\" + fileParts[0].Text;

                if (playlist.OpenPlaylistFile(playlistMP3sListView, openPlaylistFilePath) == true)
                {
                    mainSaveAsToolStripMenuItem.Enabled = true;
                }
                else
                {
                    mainSaveAsToolStripMenuItem.Enabled = false;
                }

                titleBarLabel.Text = playlist.CurrentPlaylistFileName;
                mainSaveToolStripButton.Enabled = false;
                mainSaveToolStripMenuItem.Enabled = false;
                UpdatePlaylistLabels();
            }

            /// <summary>
            /// Delete the Selected Song from the Playlist MP3s List View
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void playlistMP3sListView_MouseDoubleClick(object sender, MouseEventArgs e)
            {
                if (playlist.DeleteSongFromPlaylist(playlistMP3sListView) == true)
                {
                    if (playlist.NumberOfSongsInPlaylist == 0)
                    {
                        mainSaveToolStripButton.Enabled = false;
                        mainSaveToolStripMenuItem.Enabled = false;
                        mainSaveAsToolStripMenuItem.Enabled = false;
                    }
                    else
                    {
                        mainSaveToolStripButton.Enabled = true;
                        mainSaveToolStripMenuItem.Enabled = true;
                    }
                    UpdatePlaylistLabels();
                }
            }

            /// <summary>
            /// Start to Drag & Drop the Selected Song from the Available MP3s List View
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void playlistAvailableMP3sListView_ItemDrag(object sender, ItemDragEventArgs e)
            {
                ListViewItem dragItem = playlist.GetSelectedSong(playlistAvailableMP3sListView);

                playlistAvailableMP3sListView.DoDragDrop(dragItem, DragDropEffects.Copy);
            }

            /// <summary>
            /// Allow an Item to Be Dropped on the Playlist MP3s List View
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void playlistMP3sListView_DragEnter(object sender, DragEventArgs e)
            {
                e.Effect = e.AllowedEffect;
            }

            /// <summary>
            /// If Dragging Over the Playlist MP3s List View then Show Insertion Mark
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void playlistMP3sListView_DragOver(object sender, DragEventArgs e)
            {
                // Retrieve the client coordinates of the mouse pointer.
                Point targetPoint = playlistMP3sListView.PointToClient(new Point(e.X, e.Y));

                // Retrieve the index of the item closest to the mouse pointer.
                int targetIndex = playlistMP3sListView.InsertionMark.NearestIndex(targetPoint);

                // Confirm that the mouse pointer is not over the dragged item.
                if (targetIndex > -1)
                {
                    // Determine whether the mouse pointer is to the top or
                    // the bottom of the midpoint of the closest item and set
                    // the InsertionMark.AppearsAfterItem property accordingly.
                    Rectangle itemBounds = playlistMP3sListView.GetItemRect(targetIndex);
                    if (targetPoint.Y > itemBounds.Top + (itemBounds.Height / 2))
                    {
                        playlistMP3sListView.InsertionMark.AppearsAfterItem = true;
                    }
                    else
                    {
                        playlistMP3sListView.InsertionMark.AppearsAfterItem = false;
                    }
                }

                // Set the location of the insertion mark. If the mouse is
                // over the dragged item, the targetIndex value is -1 and
                // the insertion mark disappears.
                playlistMP3sListView.InsertionMark.Index = targetIndex;
            }

            /// <summary>
            /// If not Dragging Over the Playlist MP3s List View then Don't Show Insertion Mark
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void playlistMP3sListView_DragLeave(object sender, EventArgs e)
            {
                playlistMP3sListView.InsertionMark.Index = -1;
            }

            /// <summary>
            /// Drop the Selected Song on the Playlist MP3s List View
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void playlistMP3sListView_DragDrop(object sender, DragEventArgs e)
            {
                // Retrieve the index of the insertion mark;
                int targetIndex = playlistMP3sListView.InsertionMark.Index;


                // If the insertion mark is to the bottom of the item with
                // the corresponding index, increment the target index.
                if (playlistMP3sListView.InsertionMark.AppearsAfterItem)
                {
                    targetIndex++;
                }

                ListViewItem draggedItem = (ListViewItem)e.Data.GetData(typeof(ListViewItem));

                if (draggedItem.SubItems[0].Text == "Error")
                {
                    //Error Item
                    return;
                }

                playlist.AddSongToPlaylist(playlistMP3sListView, draggedItem, targetIndex);

                mainSaveToolStripButton.Enabled = true;
                mainSaveToolStripMenuItem.Enabled = true;
                mainSaveAsToolStripMenuItem.Enabled = true;
                UpdatePlaylistLabels();
            }

            /// <summary>
            /// Start Drag & Drop Selected Song from the Playlist MP3s List View
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void playlistMP3sListView_ItemDrag(object sender, ItemDragEventArgs e)
            {
                ListViewItem dragItem = playlist.GetSelectedPlaylistItem(playlistMP3sListView);

                playlistMP3sListView.DoDragDrop(dragItem, DragDropEffects.Move);
            }

            /// <summary>
            /// Allow an Song from the Playlist MP3s List View to be Dropped on the Available MP3s List View
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void playlistAvailableMP3sListView_DragEnter(object sender, DragEventArgs e)
            {

                ListViewItem draggedItem = (ListViewItem)e.Data.GetData(typeof(ListViewItem));

                if (draggedItem.SubItems[2].Text == "playlistMP3sListView")
                {
                    e.Effect = e.AllowedEffect;
                }
                else
                {
                    e.Effect = DragDropEffects.None;
                }
            }

            /// <summary>
            /// Delete the Selected Song from the Playlist MP3s List View
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void playlistAvailableMP3sListView_DragDrop(object sender, DragEventArgs e)
            {
                ListViewItem draggedItem = (ListViewItem)e.Data.GetData(typeof(ListViewItem));

                if (draggedItem.SubItems[2].Text != "playlistMP3sListView")
                {
                    return;
                }

                if (playlist.DeleteSongFromPlaylist(playlistMP3sListView) == true)
                {
                    if (playlist.NumberOfSongsInPlaylist == 0)
                    {
                        mainSaveToolStripButton.Enabled = false;
                        mainSaveToolStripMenuItem.Enabled = false;
                        mainSaveAsToolStripMenuItem.Enabled = false;
                    }
                    else
                    {
                        mainSaveToolStripButton.Enabled = true;
                        mainSaveToolStripMenuItem.Enabled = true;
                    }
                    UpdatePlaylistLabels();
                }
            }

            #endregion Playlist Events

            #region Schedule Events

            /// <summary>
            /// Set the Calendar Time Scale to 1 Minute
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void schedule1MinuteTimeScaleRadioButton_CheckedChanged(object sender, EventArgs e)
            {
                if (schedule1MinuteTimeScaleRadioButton.Checked == true)
                {
                    scheduleCalendar.TimeScale = CalendarTimeScale.OneMinute;
                }
            }

            /// <summary>
            /// Set the Calendar Time Scale to 5 Minutes
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void schedule5MinuteTimeScaleRadioButton_CheckedChanged(object sender, EventArgs e)
            {
                if (schedule5MinuteTimeScaleRadioButton.Checked == true)
                {
                    scheduleCalendar.TimeScale = CalendarTimeScale.FiveMinutes;
                }
            }

            /// <summary>
            /// Set the Calendar Time Scale to 6 Minutes
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void schedule6MinuteTimeScaleRadioButton_CheckedChanged(object sender, EventArgs e)
            {
                if (schedule6MinuteTimeScaleRadioButton.Checked == true)
                {
                    scheduleCalendar.TimeScale = CalendarTimeScale.SixMinutes;
                }
            }

            /// <summary>
            /// Set the Calendar Time Scale to 10 Minutes
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void schedule10MinuteTimeScaleRadioButton_CheckedChanged(object sender, EventArgs e)
            {
                if (schedule10MinuteTimeScaleRadioButton.Checked == true)
                {
                    scheduleCalendar.TimeScale = CalendarTimeScale.TenMinutes;
                }
            }

            /// <summary>
            /// Set the Calendar Time Scale to 15 Minutes
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void schedule15MinuteTimeScaleRadioButton_CheckedChanged(object sender, EventArgs e)
            {
                if (schedule15MinuteTimeScaleRadioButton.Checked == true)
                {
                    scheduleCalendar.TimeScale = CalendarTimeScale.FifteenMinutes;
                }
            }

            /// <summary>
            /// Set the Calendar Time Scale to 30 Minutes
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void schedule30MinuteTimeScaleRadioButton_CheckedChanged(object sender, EventArgs e)
            {
                if (schedule30MinuteTimeScaleRadioButton.Checked == true)
                {
                    scheduleCalendar.TimeScale = CalendarTimeScale.ThirtyMinutes;
                }
            }

            /// <summary>
            /// Set the Calendar Time Scale to 60 Minutes
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void schedule60MinuteTimeScaleRadioButton_CheckedChanged(object sender, EventArgs e)
            {
                if (schedule60MinuteTimeScaleRadioButton.Checked == true)
                {
                    scheduleCalendar.TimeScale = CalendarTimeScale.SixtyMinutes;
                }
            }

            /// <summary>
            /// Add a new Show to the Schedule
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void scheduleAddShowButton_Click(object sender, EventArgs e)
            {
                if (schedule.AddScheduleItem(scheduleCalendar, "Show") == true)
                {
                    mainSaveToolStripButton.Enabled = scheduleCalendar.CalendarNeedsToBeSaved;
                    mainSaveToolStripMenuItem.Enabled = scheduleCalendar.CalendarNeedsToBeSaved;
                    mainSaveAsToolStripMenuItem.Enabled = scheduleCalendar.CalendarNeedsToBeSaved;
                    UpdateScheduleLabels();
                }
            }

            /// <summary>
            /// Add a new Playlist to the Schedule
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void scheduleAddPlaylistButton_Click(object sender, EventArgs e)
            {
                if (schedule.AddScheduleItem(scheduleCalendar, "Playlist") == true)
                {
                    mainSaveToolStripButton.Enabled = scheduleCalendar.CalendarNeedsToBeSaved;
                    mainSaveToolStripMenuItem.Enabled = scheduleCalendar.CalendarNeedsToBeSaved;
                    mainSaveAsToolStripMenuItem.Enabled = scheduleCalendar.CalendarNeedsToBeSaved;
                    UpdateScheduleLabels();
                }
            }

            /// <summary>
            /// Add a new Trigger to the Schedule
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void scheduleAddTriggerButton_Click(object sender, EventArgs e)
            {
                if (schedule.AddScheduleItem(scheduleCalendar, "Trigger") == true)
                {
                    mainSaveToolStripButton.Enabled = scheduleCalendar.CalendarNeedsToBeSaved;
                    mainSaveToolStripMenuItem.Enabled = scheduleCalendar.CalendarNeedsToBeSaved;
                    mainSaveAsToolStripMenuItem.Enabled = scheduleCalendar.CalendarNeedsToBeSaved;
                    UpdateScheduleLabels();
                }
            }

            /// <summary>
            /// Enable the Delete button if an Item has been selected
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void scheduleCalendar_MouseClick(object sender, MouseEventArgs e)
            {
                if (scheduleCalendar.State == Calendar.CalendarState.DraggingItem ||
                    scheduleCalendar.State == Calendar.CalendarState.ResizingItem ||
                    scheduleCalendar.State == Calendar.CalendarState.EditingItemText)
                {
                    scheduleDeleteItemButton.Enabled = true;
                }
                else
                {
                    scheduleDeleteItemButton.Enabled = false;
                }
            }

            /// <summary>
            /// Delete the selected Item
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void scheduleDeleteItemButton_Click(object sender, EventArgs e)
            {
                if (schedule.DeleteScheduleItems(scheduleCalendar) == true)
                {
                    scheduleDeleteItemButton.Enabled = false;
                    mainSaveToolStripButton.Enabled = scheduleCalendar.CalendarNeedsToBeSaved;
                    mainSaveToolStripMenuItem.Enabled = scheduleCalendar.CalendarNeedsToBeSaved;
                    mainSaveAsToolStripMenuItem.Enabled = scheduleCalendar.CalendarNeedsToBeSaved;
                    UpdateScheduleLabels();
                }
            }

            private void scheduleCalendar_ItemDoubleClick(object sender, CalendarItemEventArgs e)
            {
                if (schedule.EditScheduleItem(scheduleCalendar) == true)
                {
                    scheduleDeleteItemButton.Enabled = false;
                    mainSaveToolStripButton.Enabled = scheduleCalendar.CalendarNeedsToBeSaved;
                    mainSaveToolStripMenuItem.Enabled = scheduleCalendar.CalendarNeedsToBeSaved;
                    mainSaveAsToolStripMenuItem.Enabled = scheduleCalendar.CalendarNeedsToBeSaved;
                    UpdateScheduleLabels();
                }
            }

            private void scheduleCalendar_KeyDown(object sender, KeyEventArgs e)
            {
                if (e.KeyCode == Keys.Delete)
                {
                    if (schedule.DeleteScheduleItems(scheduleCalendar) == true)
                    {
                        scheduleDeleteItemButton.Enabled = false;
                        mainSaveToolStripButton.Enabled = scheduleCalendar.CalendarNeedsToBeSaved;
                        mainSaveToolStripMenuItem.Enabled = scheduleCalendar.CalendarNeedsToBeSaved;
                        mainSaveAsToolStripMenuItem.Enabled = scheduleCalendar.CalendarNeedsToBeSaved;
                        UpdateScheduleLabels();
                    }
                }
            }

            private void savedSchedulesListView_DoubleClick(object sender, EventArgs e)
            {
                ListView.SelectedListViewItemCollection selectedFile = savedSchedulesListView.SelectedItems;

                ListViewItem.ListViewSubItemCollection fileParts = selectedFile[0].SubItems;

                string openScheduleFilePath = fileParts[1].Text + @"\" + fileParts[0].Text;
                if (schedule.OpenSchedule(scheduleCalendar, openScheduleFilePath) == true)
                {
                    mainSaveAsToolStripMenuItem.Enabled = true;
                    mainSaveToolStripButton.Enabled = false;
                    mainSaveToolStripMenuItem.Enabled = false;
                }

                UpdateScheduleLabels();
                titleBarLabel.Text = schedule.CurrentScheduleFileName;
            }

            private void scheduleCalendar_MouseUp(object sender, MouseEventArgs e)
            {
                mainSaveToolStripButton.Enabled = scheduleCalendar.CalendarNeedsToBeSaved;
                mainSaveToolStripMenuItem.Enabled = scheduleCalendar.CalendarNeedsToBeSaved;
                schedule.UpdateScheduleItemCount(scheduleCalendar);
                UpdateScheduleLabels();
            }

            #endregion Schedule Events

            #region Menu Events

            /// <summary>
            /// 
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void mainSaveAsToolStripMenuItem_Click(object sender, EventArgs e)
            {
                string activeNavigationBand = mainNavigationBar.ActiveBand.Text;

                switch (activeNavigationBand)
                {
                    case "Channel Maps":
                        {
                            //Try to save the current Channel Map with a New File Name
                            if (channelMap.SaveAsChannelMap(channelMapListView) == true)
                            {
                                //Update the Saved Channel Map List View
                                channelMap.PopulateSavedChannelMapListView(savedChannelMapListView);

                                //Update the Main Form Title Bar
                                titleBarLabel.Text = channelMap.CurrentChannelMapFileName;

                                //Update the Menu and Tool Bar
                                mainSaveToolStripButton.Enabled = false;
                                mainSaveToolStripMenuItem.Enabled = false;
                            }
                            else
                            {
                                MessageBox.Show("Error Saving Channel Map");
                            }
                        }//end Case: Channel Maps
                        break;

                    case "Shows":
                        {
                            //Try to save the current Show with a New File Name
                            if (show.SaveAsShow(showSequencesListView) == true)
                            {
                                //Update the Saved Channel Map List View
                                show.PopulateSavedShowListView(savedShowListView);

                                //Update the Main Form Title Bar
                                titleBarLabel.Text = show.CurrentShowFileName;

                                //Update the Menu and Tool Bar
                                mainSaveToolStripButton.Enabled = false;
                                mainSaveToolStripMenuItem.Enabled = false;
                            }
                            else
                            {
                                MessageBox.Show("Error Saving Channel Map");
                            }
                        }
                        break;

                    case "Schedules":
                        {
                            //Try to save the current Schedule with a New File Name
                            if (schedule.SaveAsSchedule(scheduleCalendar) == true)
                            {
                                //Update the Saved Schedules List View
                                schedule.PopulateScheduleListView(savedSchedulesListView);

                                //Update the Main Form Title Bar
                                titleBarLabel.Text = schedule.CurrentScheduleFileName;

                                //Update the Menu and Tool Bar
                                mainSaveToolStripButton.Enabled = false;
                                mainSaveToolStripMenuItem.Enabled = false;
                            }
                            else
                            {
                                MessageBox.Show("Error Saving Schedule");
                            }
                        }
                        break;

                    default:
                        {
                            MessageBox.Show("This feature isn't implemented yet.");
                        }
                        break;
                }//end switch
            }//end mainSaveAsToolStripMenuItem_Click

            /// <summary>
            /// Save the Currently Selected Object
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void mainSaveToolStripMenuItem_Click(object sender, EventArgs e)
            {
                SaveHelixObjects();
            }

            /// <summary>
            /// Save the Currently Selected Object
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void mainSaveToolStripButton_Click(object sender, EventArgs e)
            {
                SaveHelixObjects();
            }

            /// <summary>
            /// Create a New Helix Object
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void mainNewToolStripButton_Click(object sender, EventArgs e)
            {
                NewHelixObject();
            }//end mainNewToolStripButton_Click

            /// <summary>
            /// Create a New Helix Object
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void mainNewToolStripMenuItem_Click(object sender, EventArgs e)
            {
                NewHelixObject();
            }

            /// <summary>
            /// Open an Existing Helix Object
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void mainOpenToolStripMenuItem_Click(object sender, EventArgs e)
            {
                OpenHelixObject();
            }

            /// <summary>
            /// Open an Existing Helix Object
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void mainOpenToolStripButton_Click(object sender, EventArgs e)
            {
                OpenHelixObject();
            }

            #endregion Menu Events

            #region Context Menu Events
            /// <summary>
            /// Open the File Selected in the Saved List View
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void savedLVOpenContextMenuItem_Click(object sender, EventArgs e)
            {
                string openFileFullPath = "";
                //Get the text of the currently selected Navigation Band
                string selectedNavigationButtonText = mainNavigationBar.ActiveBand.Text;

                //Update the selected Helix Object based upon the selected Navigation Band
                switch (selectedNavigationButtonText)
                {
                    case "Channel Maps":
                        {
                            ListView.SelectedListViewItemCollection selectedFile = savedChannelMapListView.SelectedItems;
                            ListViewItem.ListViewSubItemCollection fileParts = selectedFile[0].SubItems;

                            //Assemble the full path to the file to be deleted
                            openFileFullPath = fileParts[1].Text + @"\" + fileParts[0].Text;

                            if (channelMap.OpenChannelMap(channelMapListView, openFileFullPath) == true)
                            {
                                mainSaveAsToolStripMenuItem.Enabled = true;
                                channelMapEditHelixSystemButton.Enabled = true;
                                channelMapDeleteHelixSystemButton.Enabled = true;
                            }
                            else
                            {
                                mainSaveAsToolStripMenuItem.Enabled = false;
                                channelMapEditHelixSystemButton.Enabled = false;
                                channelMapDeleteHelixSystemButton.Enabled = false;
                            }

                            titleBarLabel.Text = channelMap.CurrentChannelMapFileName;
                            mainSaveToolStripButton.Enabled = false;
                            mainSaveToolStripMenuItem.Enabled = false;
                        }
                        break;

                    case "Shows":
                        {
                            ListView.SelectedListViewItemCollection selectedFile = savedShowListView.SelectedItems;
                            ListViewItem.ListViewSubItemCollection fileParts = selectedFile[0].SubItems;

                            //Assemble the full path to the file to be deleted
                            openFileFullPath = fileParts[1].Text + @"\" + fileParts[0].Text;

                            if (show.OpenShowFile(showSequencesListView, openFileFullPath) == true)
                            {
                                mainSaveAsToolStripMenuItem.Enabled = true;
                            }
                            else
                            {
                                mainSaveAsToolStripMenuItem.Enabled = false;
                            }

                            titleBarLabel.Text = show.CurrentShowFileName;
                            mainSaveToolStripButton.Enabled = false;
                            mainSaveToolStripMenuItem.Enabled = false;
                        }
                        break;

                    default:
                        {
                            MessageBox.Show("This feature isn't implemented yet.");
                        }
                        break;
                }
            }

            /// <summary>
            /// Deleted the File Selected in the Saved List View
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void savedLVDeleteContextMenuItem_Click(object sender, EventArgs e)
            {
                //Get the text of the currently selected Navigation Band
                string selectedNavigationButtonText = mainNavigationBar.ActiveBand.Text;

                string deleteFileFullPath = "";

                //Update the selected Helix Object based upon the selected Navigation Band
                switch (selectedNavigationButtonText)
                {
                    case "Channel Maps":
                        {
                            ListView.SelectedListViewItemCollection selectedFile = savedChannelMapListView.SelectedItems;
                            ListViewItem.ListViewSubItemCollection fileParts = selectedFile[0].SubItems;

                            //Assemble the full path to the file to be deleted
                            deleteFileFullPath = fileParts[1].Text + @"\" + fileParts[0].Text;

                            //Delete the file
                            DeleteHelixObject(deleteFileFullPath, fileParts[0].Text == channelMap.CurrentChannelMapFileName);

                            //Refresh the Saved Channel Map List View
                            channelMap.PopulateSavedChannelMapListView(savedChannelMapListView);
                        }
                        break;

                    case "Shows":
                        {
                            ListView.SelectedListViewItemCollection selectedFile = savedShowListView.SelectedItems;
                            ListViewItem.ListViewSubItemCollection fileParts = selectedFile[0].SubItems;

                            //Assemble the full path to the file to be deleted
                            deleteFileFullPath = fileParts[1].Text + @"\" + fileParts[0].Text;

                            //Delete the file
                            DeleteHelixObject(deleteFileFullPath, fileParts[0].Text == show.CurrentShowFileName);

                            //Refresh the Saved Channel Map List View
                            show.PopulateSavedShowListView(savedShowListView);
                        }
                        break;
                    default:
                        {
                            MessageBox.Show("This feature isn't implemented yet.");
                        }
                        break;
                }
            }

            #endregion Context Menu Events

            /// <summary>
            /// Check to See if Any Helix Object Needs to be Saved and Save the AppSettings
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
            {
                if (channelMap.ChannelMapNeedsToBeSaved)
                {
                    DialogResult dR = MessageBox.Show("The current channel map has not been saved.  \rSave the current channel map?",
                        "Helix Channel Map Warning", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning);
                    if (dR == DialogResult.Yes)
                    {
                        channelMap.SaveChannelMap(channelMapListView);
                    }
                    else if (dR == DialogResult.Cancel)
                    {
                        e.Cancel = true;
                    }
                }

                if (show.ShowNeedsToBeSaved)
                {
                    DialogResult dR = MessageBox.Show("The current show has not been saved.  \rSave the current show?",
                         "Helix Show Builder Warning", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning);
                    if (dR == DialogResult.Yes)
                    {
                        show.SaveShowFile(showSequencesListView);
                    }
                    else if (dR == DialogResult.Cancel)
                    {
                        e.Cancel = true;
                    }
                }

                if (playlist.PlayListNeedsToBeSaved)
                {
                    DialogResult dR = MessageBox.Show("The current playlist has not been saved.  \rSave the current playlist?",
                         "Helix Playlist Warning", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning);
                    if (dR == DialogResult.Yes)
                    {
                        playlist.SavePlaylistFile(playlistMP3sListView);
                    }
                    else if (dR == DialogResult.Cancel)
                    {
                        e.Cancel = true;
                    }
                }

                if (scheduleCalendar.CalendarNeedsToBeSaved)
                {
                    DialogResult dR = MessageBox.Show("The current schedule has not been saved.  \rSave the current schedule?",
                         "Helix Schedule Warning", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning);
                    if (dR == DialogResult.Yes)
                    {
                        //playlist.SavePlaylistFile(playlistMP3sListView);
                    }
                    else if (dR == DialogResult.Cancel)
                    {
                        e.Cancel = true;
                    }
                }
                //Save the settings

                //SaveNavigationBarSettings();

                appSettings.SaveApplicationSettings();
            }

            private void MainForm_Resize(object sender, EventArgs e)
            {
                UpdateMainForm();
            }

        #endregion Events

            private void scheduleCalendar_ItemDatesChanged(object sender, CalendarItemEventArgs e)
            {
                UpdateScheduleLabels();
            }

            private void xBeeBaudRateComboBox_SelectedIndexChanged(object sender, EventArgs e)
            {
                try
                {
                    appSettings.BaudRate = int.Parse(xBeeBaudRateComboBox.SelectedItem.ToString());
                }
                catch { }
            }

            private void xBeeComPortComboBox_DropDown(object sender, EventArgs e)
            {
                xBeeComPortComboBox.Items.Clear();
                xBee.setPortNames(xBeeComPortComboBox);
            }

            private void xBeeComPortComboBox_SelectedIndexChanged(object sender, EventArgs e)
            {
                xBee.savePortName(xBeeComPortComboBox);
            }

            private void button1_Click(object sender, EventArgs e)
            {
                if (xBee.openXBee() == true)
                {
                    MessageBox.Show("Success");
                }
                else
                {
                    MessageBox.Show("Failed");
                }
            }

    }
}
